Skip to content

Conversation

@bbrk24
Copy link
Contributor

@bbrk24 bbrk24 commented Nov 6, 2025

Fixes #233

Each backend has its own shortcomings:

  • UIKitBackend has weird availability constraints on each picker style, doesn't support hourMinuteAndSecond, and doesn't respect font color
    • Furthermore, UIDatePicker doesn't exist on tvOS
  • AppKitBackend doesn't support the wheel picker style
  • WinUIBackend doesn't support hourMinuteAndSecond, doesn't respect font color, and doesn't respect environment.timeZone (instead always using the current time zone)
  • GtkBackend only supports the graphical picker style, doesn't respect environment.timeZone (instead always using the current time zone), and only supports picking the date, not the time
  • Gtk3Backend is unimplemented as I have no way to test it.

@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 6, 2025

The thought just occurred to me to observe NSSystemTimeZoneDidChange to properly redraw views that use @Environment(\.timeZone), but I'm unsure how that would work, and regardless I don't see an equivalent for the calendar.

@stackotter
Copy link
Collaborator

There’s a backend method called setEnvironmentChangeHandler or something like that. That’s where we currently observe system theme changes and would be where timezone observation should live as well.

@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 7, 2025

Right, I'll go see if I can get that to work in UIKitBackend and AppKitBackend first, and then maybe the other backends. I don't think it'll necessarily work on Linux though

@bbrk24 bbrk24 marked this pull request as draft November 7, 2025 18:53
@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 7, 2025

Marking this as draft because UIDatePicker (at least on iOS 17) completely misbehaves if the user changes the time zone in settings

@bbrk24 bbrk24 marked this pull request as ready for review November 8, 2025 00:34
Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this super detailed PR! Safari was lagging the entire time that I was reviewing your changes lol. I've left a bunch of requests and comments from an initial read through of all of the code.

I haven't had time to test out the changes myself yet, but I'll make sure to do that before merging and will update the PR with any additional feedback I have after testing things out.

Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the DatePicker example is relatively simple, I reckon it could make sense to merge it into ControlsExample.

@stackotter
Copy link
Collaborator

I think I've gone through and closed all of the review comments that have been addressed and commented on ones that I have more questions about.

Regarding the GtkBackend TimePicker implementation: when I originally reviewed it I didn't realise that it's unused. If you'd like, feel free to turn my current comments on it into todo comments and document clearly that the class is neither ready nor used, and I'd count those comments as resolved. I more just want to avoid another contributor coming along and trying to use it assuming that it's meant to work properly in its current form.

@bbrk24 bbrk24 requested a review from stackotter December 19, 2025 02:25
Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow GitHub just had some of these comments pending from a while ago. I guess I must've left the review halfway through?

There's also this comment unresolved from a while ago: #244 (comment) . What do you reckon about that idea?

Looking good now though. Happy to merge once the GDateTime documentation comment is addressed and these changes have been rebased onto main.

@stackotter
Copy link
Collaborator

I think you'll have to run ./generate.sh && ./format_and_lint.sh to fix those Gtk build issues. I changed some things about the generation

@bbrk24
Copy link
Contributor Author

bbrk24 commented Jan 7, 2026

Now that the DatePicker example is relatively simple, I reckon it could make sense to merge it into ControlsExample.

Done, and added a #if so that it can still run in Gtk3Backend (which doesn't implement pickers).

VStack {
Text("Selected date: \(date)")

Picker(of: supportedDatePickerStyles, selection: $datePickerStyle)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this in an HStack along with a label (like above for the flavour picker) so that it's clear what the picker is for


Picker(of: supportedDatePickerStyles, selection: $datePickerStyle)

DatePicker(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the entirety of ControlsExample into a ScrollView because it's gotten pretty tall now (too tall for my laptop display). I probably should've done that a while ago

@stackotter
Copy link
Collaborator

I've just been testing out the ControlsExample on my various machines, and noticed that the GtkBackend really spams the time picker not implemented warning. It might be worth updating it to only log that message the first time it's triggered. I believe that one of the other backends has a mechanism to do that already, maybe UIKitBackend from some of Mia's changes?

bbrk24 added 2 commits January 6, 2026 23:32
Add DatePicker for AppKitBackend

Add DatePickerExample to macOS CI

Fix DatePicker update logic for AppKitBackend

Update argument name to match SwiftUI

Add more availability annotations

Shut up tvOS let me see if the iOS CI will pass

please work.

Fine, here's your view

Initial WinUI implementation

Reformat WinUI code

Implement minYear/maxYear for DatePicker

Improve WinUI sizing code

Fix CalendarDatePicker size

Minor cleanup

Generate GTK classes and improve manual type conversion

oops

Fix casing of calendar name

Saving partial work on GtkBackend

More partial work

Use Gtk.Calendar

Add missing parts to GtkBackend.updateDatePicker

Add DatePickerExample to Linux CI

Fix one Mac availability error

Add availability annotation on unused widget

Add time zone listener for UIKitBackend

Add listener for AppKitBackend

Address some PR comments

Update some doc comments

Support date-only pickers in AppKitBackend

Change default timezone and calendar from autoupdatingCurrent to current

Address more PR comments

tvOS please compile first try

Fixes after rebase

Update GTK 4 bindings

Update Gtk3 sources

Update DummyBackend

Address PR comments

Add scroll view and implement range on GtkBackend

Fix CI and add HStack
@stackotter
Copy link
Collaborator

When I click a day in the GtkBackend Calendar picker, it selects the day prior for some reason 🤔

@stackotter
Copy link
Collaborator

And when I click 'reset date to now', the focus ring stays on the date that I previously selected, rather than the programatically selected date. Maybe that's just a Gtk thing though?

@bbrk24 bbrk24 requested a review from stackotter January 8, 2026 04:30
stackotter
stackotter previously approved these changes Jan 9, 2026
Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience with this one 🙏

@stackotter
Copy link
Collaborator

I'll test locally while waiting for CI, then merge if all goes well.

@stackotter
Copy link
Collaborator

Damn, merging in the changes from main caused WinUIBackend compilation to fail. It appears to be because I moved the implementation of naturalSize to a static method for convenience when implementing WinUIElementRepresentable. This patch fixes things for me;

WinUIBackendFixes.patch

I also removed the picker's label because it was line wrapping and causing the date picker to be really tall with no visible reason when the window was skinny enough. I tried making the label fixedSize but for some reason that did nothing.

@stackotter
Copy link
Collaborator

And while testing on Windows I found that the graphical calendar view lets you unselect your selection without selecting anything else. I think in that case we should just programatically reselect the selected day again.

@bbrk24 bbrk24 requested a review from stackotter January 10, 2026 02:51
stackotter
stackotter previously approved these changes Jan 11, 2026
@stackotter
Copy link
Collaborator

Will merge once CI finishes (it got re-triggered because I had to resolve a merge conflict)

@stackotter stackotter merged commit 425ff88 into moreSwift:main Jan 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date Picker

2 participants